﻿using System;
using System.Xml;
using Dsl.Ped.Framework.Common;

namespace Dsl.Ped.Editor.Services
{
    /// <summary>
    /// Interface, that must be implemented for the <see cref="IProjective"/> object handling
    /// </summary>
    public interface IProjectiveObjectService
    {
        /// <summary>
        /// Gets the name of a file which was the current <see cref="IProjective"/> object loaded from
        /// </summary>
        string CurrentFileName { get; }

        /// <summary>
        /// Gets the <see cref="Type"/> of the current <see cref="IProjective"/> object
        /// </summary>
        Type CurrentProjectiveType { get; }

        /// <summary>
        /// Gets the Xml Namespace of the loaded file
        /// </summary>
        string CurrentXmlNamespace { get; }

        /// <summary>
        /// Gets the current <see cref="IProjective"/> treated by this service
        /// </summary>
        IProjective CurrentProjectiveObject { get; }

        /// <summary>
        /// Load the <see cref="IProjective"/> object from the file
        /// </summary>
        /// <param name="fileName">Name of the file which the <see cref="IProjective"/> object should be loaded from</param>
        /// <returns>True, if the file was loaded successfully</returns>
        bool LoadFromFile(string fileName);

        /// <summary>
        /// Load the <see cref="IProjective"/> object from the file using the given <see cref="XmlReader"/>
        /// </summary>
        /// <param name="fileName">Name of the file which the <see cref="IProjective"/> object should be loaded from</param>
        /// <param name="xmlReader"><see cref="XmlReader"/> used for the load of an object</param>
        /// <returns>True, if the file was loaded successfully</returns>
        bool LoadFromFile(string fileName, XmlReader xmlReader);

        /// <summary>
        /// Reload the <see cref="IProjective"/> object from the file of the <see cref="CurrentFileName"/> name
        /// </summary>
        /// <returns>True, if the file was reloaded successfully</returns>
        bool ReloadFromFile();

        /// <summary>
        /// Save the <see cref="CurrentProjectiveObject"/> to the file of <see cref="CurrentFileName"/> name
        /// </summary>
        /// <returns>True, if the file was saved successfully</returns>
        bool Store2File();

        /// <summary>
        /// Save the <see cref="CurrentProjectiveObject"/> to the file of a given <see cref="fileName"/> name
        /// </summary>
        /// <param name="fileName">Name of the file which the <see cref="IProjective"/> object should be stored to</param>
        /// <returns>True, if the <see cref="IProjective"/> object was stored successfully</returns>
        bool Store2File(string fileName);

        /// <summary>
        /// Create new <see cref="IProjective"/> object of the given name an associate the file with the <see cref="CurrentProjectiveObject"/>
        /// </summary>
        /// <param name="projectiveType">Type of the projective object which should be created</param>
        /// <returns>True, if the <see cref="IProjective"/> object has been instantiated successfully out of the provided <see cref="projectiveType"/></returns>
        bool CreateNewProjectiveObject(Type projectiveType);

        /// <summary>
        /// Create new <see cref="IProjective"/> object of the given name an associate the file with the <see cref="CurrentProjectiveObject"/>
        /// Use provided object as a default one.
        /// </summary>
        /// <param name="projectiveType">Type of the projective object which should be created</param>
        /// <returns>True, if the <see cref="IProjective"/> object has been instantiated successfully out of the provided <see cref="projectiveType"/></returns>
        bool CreateNewProjectiveObject(Type projectiveType, object defaultObject);
    }
}
